package com.woniuxy.his.controller;

import com.woniuxy.his.common.Result;
import com.woniuxy.his.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;
import java.security.NoSuchAlgorithmException;

@RestController
@CrossOrigin("*")
@Slf4j
public class UserController {

    @Resource
    private IUserService userService;

    @GetMapping("/addUser")
    public Result addUser(String username,String password) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        log.info("添加username：{}，password:{}",username,password);
        Integer integer = userService.addUser(username, password);
        if(1<=integer){
            log.info("如果添加大于1");
            return Result.success("2000","添加成功",integer);
        }
        return Result.fail("4000","添加失败",null);
    }


}
